package com.hxd.otc.module.wallet.presenter;

import android.support.annotation.NonNull;

import com.hxd.otc.base.BaseBean;
import com.hxd.otc.module.wallet.contract.WalletCoinWithdrawContract;
import com.hxd.otc.module.wallet.model.WalletModel;
import com.hxd.otc.mvp.base.BasePresenter;
import com.hxd.otc.net.BaseObserver;

/**
 * 包  名 :  com.hxd.otc.mvp.wallet
 * 类  名 :  CoinWithdrawPresenter
 * 作  者 :  卫广玉
 * 时  间 :  2018/6/5 18:18
 * 描  述 :  提币
 */
public class CoinWithdrawPresenter extends BasePresenter<WalletCoinWithdrawContract.View> implements WalletCoinWithdrawContract.Presenter {

    private final WalletModel mModel;


    public CoinWithdrawPresenter(WalletCoinWithdrawContract.View view) {
        super(view);
        mModel = WalletModel.getInstance();
    }

    @Override
    public void start() {

    }


    @Override
    public void postGooleValidate(String id, String googleCode) {
        mModel.postGooleValidate(new BaseObserver() {
            @Override
            public void onNext(@NonNull String msg, @NonNull Object o) {

                mView.Success();
            }

            @Override
            public void onError(int errType, @NonNull String errMessage) {

                mView.showToast(errMessage);
            }

        }, mView.<BaseBean>bindAutoDispose(), id, googleCode);

    }

    @Override
    public void coinWithdraw(String... paramters) {
        //转账不可重复点击
        mView.setTransferEnable(false);
        mView.onShowLoading();
        mModel.coinWithdraw(new BaseObserver() {
            @Override
            public void onNext(String id, Object object) {
                mView.onHideLoading();
                mView.transferSuccess(object.toString());
                mView.setTransferEnable(true);
            }

            @Override
            public void onError(int errType, String errMessage) {
                mView.onHideLoading();
                mView.showToast(errMessage);
                mView.setTransferEnable(true);
            }
        }, mView.<BaseBean>bindAutoDispose(), paramters);
    }


}
